﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using COFE.IO;

namespace COFE.Core.Tasks
{
    public static class IEntryListActionExtension
    {
        /// <summary>
        /// The following have to be set to run the action.
        ///  COFETaskShared.ParentTaskId = parentTaskId
        ///  COFETaskShared.TaskStage = taskStage;
        ///  COFETaskShared.CancellationToken = token;
        /// </summary>
        /// <param name="entryList"></param>
        /// <param name="action"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static Func<IEntryList, string, IEntryList> GetAction(this IEntryList entryList,  object action, string param)
        {
            if (!entryList.IsPropertySupported(action, PropertyRetrivalOptions.NotApplied))
                throw new NotSupportedException();

            PropertyPair ppair = entryList.GetProperty(action, PropertyRetrivalOptions.NotApplied);

            return (Func<IEntryList, string, IEntryList>)ppair.Value;            
        }

       
    }
}
